from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from unittest import runner

# 打开浏览器
driver = webdriver.Chrome()
# 访问的网页
driver.get('http://192.168.1.25/crm')
driver.implicitly_wait(30)
# 最大化窗口
driver.maximize_window()

username = '杨应科'
password = '123456'

# 定位器
username_locator = (By.NAME,'name')
password_locator = (By.NAME,'password')
dl_locator= (By.NAME,'submit')
tianjiazujian_locator = (By.ID,'add')
zhujianming_locator = (By.ID,'title')
baocun_locator = (By.CSS_SELECTOR,'#dialog-message > form > div:nth-child(4) > div > input.btn.btn-primary')

# 执行
driver.find_element(*username_locator).send_keys(username)
driver.find_element(*password_locator).send_keys(password)
driver.find_element(*dl_locator).click()
driver.find_element(*tianjiazujian_locator).click()
driver.find_element(*zhujianming_locator).send_keys('月销')
sleep(2)
driver.find_element(*baocun_locator).click()
sleep(3)
driver.quit()